<?php

namespace app\common\model;
/**
 * [ManagerCompany  法师寺院关联表]
 * @author [C。]
 * @return html
 */
class ManagerCompany extends Base
{
    protected $name = 'manager_company';
    /**
     * 根据搜索条件获取列表信息
     */
    public function getList($map, $from=0, $size = 5)
    {
        $order = ['ma.id' => 'desc'];
        $join1 = [
            ['app_member me','me.tel = ma.tel'],
        ];
        $join2 = [
            ['app_manager ma','ma.id = mc.mid'],
        ];
        $field = 'ma.id,me.img,ma.name,ma.username,me.tel,mc.dutyid,me.sex,me.bathday,me.conversiontime,mc.jobid';
        $result =  $this->field($field)
            ->alias('mc')
            ->join($join2)
            ->join($join1)
            ->where($map)
            ->limit($from, $size)
            ->order($order)
            ->select();

        return $result;
    }
    /**
     * 根据条件来获取列表的数据的总数
     * @param array $param
     */
    public function getCount($map = []) {
        $join1 = [
            ['app_member me','me.tel = ma.tel'],
        ];
        $join2 = [
            ['app_manager ma','ma.id = mc.mid'],
        ];
        $result =  $this
            ->alias('mc')
            ->join($join2)
            ->join($join1)
            ->where($map)
            ->count();

        return $result;
    }
}